package com.ruoyi.web.constant;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.http.HttpUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

@Slf4j
public class AoTest {

    public static void main(String[] args) {
        test();
    }

    private static void test() {
        JSONObject data = HttpUtils.httpJson("https://api.api168168.com/pks/getPksHistoryList.do?date=2025-04-24&lotCode=10012", "get", null, null);
        JSONArray array;
        if ("0".equals(data.getString("errorCode"))
                && CollUtil.isNotEmpty(data = data.getJSONObject("result"))
                && CollUtil.isNotEmpty(array = data.getJSONArray("data"))) {
            data = array.getJSONObject(0);
            String preDrawIssue = data.getString("preDrawIssue");
            log.info("ao10===>{}", preDrawIssue);
            judge(array);

        }
    }

    public static void judge(JSONArray array) {
        for (int i = array.size() - 1; i >= 0; i--) {
            JSONObject data = array.getJSONObject(i);

            String[] codes = data.getString("preDrawCode").split(",");
            Integer preDrawIssue = data.getInteger("preDrawIssue");
            List<String> msgs = new ArrayList<>();
            msgs.add(preDrawIssue + "");
            msgs.add(data.getString("preDrawCode"));

            Integer code1 = Integer.valueOf(codes[0]);
            Integer code2 = Integer.valueOf(codes[1]);
            Integer code3 = Integer.valueOf(codes[2]);
            Integer code4 = Integer.valueOf(codes[3]);
            Integer code5 = Integer.valueOf(codes[4]);
            if (code1 > code2 && code2 > code3 && code3 > code4) {
                String msg = StrUtil.format("{}\t{}", (array.size() - i), preDrawIssue);
                msgs.add(msg);
                log.info(msg);
            }
        }

    }
}
